<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>

</head>
<body>
    <!-- 生命周期
        create
        mount
        update
        destroy
     -->
     <div id="app">
         <h2 @click="handleClick">{{msg}}</h2>
         
     </div>
     <script>
         new Vue({
             el:"#app",
             data:{
                 msg:"hello world"
             },
            //  vue实例被创建之前会触发的生命周期
             beforeCreate() {
                 console.log("beforeCreate")
             },
             created() {
                 console.log("created")
             },
             beforeMount() {
                 console.log("beforeMount")
             },
            //  表示vue的实例被转载到页面中的时候会触发 http请求一般是在这里发送
             mounted() {
                 console.log("mounted")
             },
            //  当data中的数据更新的时候会触发update这两个生命周期函数
             beforeUpdate() {
                 console.log("beforeUpdate")
             },
             updated() {
                 console.log("updated")
             },
             beforeDestroy() {
                 console.log("beforeDestroy")
             },
             destroyed() {
                 console.log("destroyed")
             },
             methods: {
                 handleClick(){
                     this.msg= "change"
                 }
             },
         })
     </script>
</body>
</html>